﻿using Ookii.Dialogs.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace XYAC.Framework.MonitorTireMaterialManual.Extensions
{
    public static class FolderSelector
    {
        public static string SelectFolder(string description = "请选择一个文件夹", string initialDirectory = "")
        {
            var dialog = new VistaFolderBrowserDialog
            {
                Description = description,
                UseDescriptionForTitle = true,
                ShowNewFolderButton = true
            };

            if (!string.IsNullOrEmpty(initialDirectory))
            {
                dialog.SelectedPath = initialDirectory;
            }

            bool? result = dialog.ShowDialog();

            if (result == true)
            {
                return dialog.SelectedPath;
            }
            else
            {
                return null;
            }
        }
    }
}
